package com.thekernel.youdaoyun.service;

import com.thekernel.youdaoyun.bean.User;
import com.thekernel.youdaoyun.exception.MyException;
import com.thekernel.youdaoyun.exception.impl.UserNotLoginException;
import org.springframework.stereotype.Repository;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author TheKernel
 * @Date 2019/9/12 7:16 下午
 * @Version 1.0
 * @Description User 业务层
 */
@Repository
public interface UserService {

    /**
     * 注册用户
     * @param user 用户信息(username, password, user_type 必需)
     * @return -1: Data Not Found, 0: Username Already Exist, 1: Success
     */
    int register(User user);

    /**
     * 用户登录
     * @param user 用户信息(username, password)
     * @return 用户type / -1: Data Not Found, 0: Username/password Error
     */
    User login(User user) throws MyException;

    /**
     * 修改用户信息
     * @param user 修改后的用户信息
     * @return 1: 修改成功 0: 修改失败
     * @throws MyException 权限不足等
     */
    int update(User user) throws MyException;

    /**
     * 开通会员
     * @param user 用户信息(user_id)
     * @return 1: 修改成功 -1: 修改失败
     * @throws MyException
     */
    int becomeViper(User user) throws MyException;

    /**
     * 查看用户个人资料
     * @return 用户信息
     * @throws MyException 权限不足等
     */
    User viewSelf() throws MyException;

    /**
     * 更新用户头像
     * @param avatar 用户头像
     * @return 1: 更新成功 0: 更新失败
     * @throws UserNotLoginException 用户未登录异常
     */
    int updateAvatar(MultipartFile avatar) throws UserNotLoginException;

    /**
     * 修改密码
     * @param user 用户
     * @return 1: 修改成功 -1: 修改失败
     * @throws MyException 用户未登录异常
     */
    int updatePassword(User user) throws MyException;

}
